package day20;

import java.io.File;
import java.util.HashMap;

public class File05 {
    static HashMap<String, Integer> hm = new HashMap<>();
    public static void main(String[] args){
        File f=new File("src");
        File[] files = f.listFiles();
        Find(f);
        System.out.println(hm);
    }

    private static void Find(File file) {
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isDirectory()&&file1.length()!=0) {
                Find(file1);
            }
            else if (file1.isFile()) {
                if (hm.containsKey(file1.getName().split("\\.")[1])) {
                    hm.put(file1.getName().split("\\.")[1], hm.get(file1.getName().split("\\.")[1]) + 1);
                }
                else {
                    hm.put(file1.getName().split("\\.")[1], 1);
                }
            }
        }
    }
}
